<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>跨域</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    <script>
        //需要  浏览器允许其他服务器的响应报文通过 权限
        //需要  访问的服务器允许其他服务器设置的请求头报文通过  权限
        const myAxios = axios.create({
            baseURL:"http://127.0.0.1:8090/axios",
            timeout:10000,
            headers:{token:"123.1231231.31231"}
        })
        let cancel=null
        const CancelToken = axios.CancelToken
        myAxios.get('/cors',{
            params:{
                userId:'001'
            },
            cancelToken:new CancelToken((e)=>{
                cancel=e
            })
        })
        setTimeout(() => {
            cancel()
        }, 4000);
    </script>
</body>
</html>